<?php
declare (strict_types = 1);

namespace app\model;

use think\Model;

/**
 * @property int $id
 * @property int $user_id users.id
 * @property string $created_at
 * @property string $ip_address ip 地址
 * @mixin \think\Model
 */
class UserLoginLog extends Model
{
    // 会员登录日志
    protected $table = 'user_login_logs';

    /**
     * 生成记录
     *
     * @param int    $user_id    users.id
     * @param string $ip_address ip 地址
     */
    public static function generateLog(int $user_id, string $ip_address = ''): void
    {
        $insert = [
            'user_id'       => $user_id,
            'ip_address'    => $ip_address,
            'created_at'    => date('Y-m-d H:i:s'),
        ];
        self::insert($insert);
    } // generateLog() end
}
